/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package interfaces.controlestablas;

import controladores.ControladorSocios;
import entidades.DatosInstitucionales;
import entidades.DatosPersonales;
import interfaces.ControlTabla;
import java.util.List;
import javax.swing.JTable;
import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.BeanProperty;
import org.jdesktop.swingbinding.JTableBinding;
import org.jdesktop.swingbinding.SwingBindings;

/**
 *
 * @author fcarou
 */
public class ControlSocios implements ControlTabla
{
    private ControladorSocios controlador;
    private JTableBinding binding;
    
    public ControlSocios ()
    {
        controlador = new ControladorSocios();
    }
    
    @Override
    public Object nuevaEntidad()
    {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void eliminarEntidad(Object entidad)
    {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void detalleEntidad(Object entidad)
    {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List busqueda(String cadena)
    {
        return controlador.getSocios(cadena);
    }

    @Override
    public void bind(List lista, JTable tabla)
    {
        if (binding != null)
            return;
        
        binding = SwingBindings.createJTableBinding(AutoBinding.UpdateStrategy.READ, lista, tabla);
        
        binding.addColumnBinding(BeanProperty.create("id"))
                .setColumnName("ID")
                .setColumnClass(Long.class);
        
        binding.addColumnBinding(BeanProperty.create("datosPersonales"))
                .setColumnName("Datos Personales")
                .setColumnClass(DatosPersonales.class);
        
        binding.addColumnBinding(BeanProperty.create("datosInstitucionales"))
                .setColumnName("Datos Institucionales")
                .setColumnClass(DatosInstitucionales.class);
        
        binding.bind();
    }
}
